package com.example.administrator.xiaobo.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by kk on 2017/2/7.
 */

public class MyViewpagerAdapter extends FragmentPagerAdapter {

    private String[] list;
    private List<Fragment> data;

    public MyViewpagerAdapter(FragmentManager fm, String[] list, List<Fragment> data) {
        super(fm);
        this.list = list;
        this.data = data;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data == null ? 0 : data.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list[position];
    }
}
